home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / IShield for Visual C++ 6.0 / DATA1.CAB / Include_Files / SDFINBOT.RUL < prev    next >
Encoding:
Text File  |  1997-11-20  |  9.2 KB  |  222 lines

  1.  
  2.  /*=======================================================================*/
  3.  /*                                                                       */
  4.  /*           (c) InstallShield Software Corporation (1996-1997)          */
  5.  /*            (c)  InstallShield Corporation  (1990-1996)                */
  6.  /*                       Schaumburg, Illinois 60173                      */
  7.  /*                          All Rights Reserved                          */
  8.  /*                           InstallShield (R)                           */
  9.  /*                                                                       */
  10.  /*   File    : sdfinbot.rul                                              */
  11.  /*                                                                       */
  12.  /*   Purpose : This file contains the code for the SdFinishReboot        */
  13.  /*             script dialog function.                                   */
  14.  /*                                                                       */
  15.  /*=======================================================================*/
  16.  
  17.  /*------------------------------------------------------------------------*/
  18.  /*                                                                        */
  19.  /*   Function: SdFinishReboot                                             */
  20.  /*                                                                        */
  21.  /*   Descrip:  This dialog will ask the user to agree with the completion */
  22.  /*             plans for an installation.                                 */
  23.  /*   Misc:                                                                */
  24.  /*                                                                        */
  25.  /*------------------------------------------------------------------------*/
  26. function SdFinishReboot( szTitle, szMsg, nDefOption, szMsg2, nReserved )
  27.           STRING  szDlg, szTemp;
  28.           INT     nId, list, nType, nOS, nResult;
  29.           HWND    hwndRbut, hwndDlg;
  30.           BOOL    bWin16, bDone;
  31.         begin
  32.  
  33.           szDlg     = SD_DLG_FINISHREBOOT;
  34.           nSdDialog = SD_NDLG_FINISHREBOOT;
  35.  
  36.           // determine OS to be used for restarting
  37.           bWin16 = FALSE;
  38.           GetSystemInfo( OS, nOS, szTemp );
  39.           if ((nOS = IS_WIN32S) || (nOS = IS_WINDOWS)) then
  40.              bWin16 = TRUE;
  41.           endif;
  42.  
  43.           // record data produced by this dialog
  44.           if (MODE=SILENTMODE) then
  45.             SdMakeName( szAppKey, szDlg, szTitle, nSdFinishReboot );
  46.             SilentReadData( szAppKey, "Result", DATA_NUMBER, szTemp, nId );
  47.             if ((nId != BACK) && (nId != CANCEL)) then
  48.                SilentReadData( szAppKey, "BootOption", DATA_NUMBER, szTemp, nResult );
  49.                CommitSharedFiles(0);
  50.                if (nId = -1) then // boot had failed
  51.                  return -1;
  52.                endif;
  53.  
  54.                if (nResult) then // if non 0 choice then reboot machine
  55.                  nId = System( nResult );
  56.                  if (nId < 0) then return nId; endif; // failed
  57.  
  58.                  Delay( 1 );   // wait a long time to ensure under NT reboot has time
  59.                  nId = -1; // boot failed
  60.                endif;
  61.  
  62.             endif;
  63.  
  64.             return nId;
  65.           endif;
  66.  
  67.           // ensure general initialization is complete
  68.           if (!bSdInit) then
  69.              SdInit();
  70.           endif;
  71.  
  72.           if (EzDefineDialog( szDlg, "", "", SD_NDLG_FINISHREBOOT) = DLG_ERR) then
  73.              return -1;
  74.           endif;
  75.  
  76.           // Loop in dialog until the user selects a standard button
  77.           Disable( BACKBUTTON );
  78.           bDone = FALSE;
  79.  
  80.           while (!bDone)
  81.  
  82.              nId = WaitOnDialog( szDlg );
  83.  
  84.              switch (nId)
  85.              case DLG_INIT:
  86.                   if(szMsg != "") then
  87.                       SdSetStatic( szDlg, SD_STA_MSG1, szMsg );
  88.                   endif;
  89.  
  90.                   if(szMsg2 != "") then
  91.                       SdSetStatic( szDlg, SD_STA_MSG2, szMsg2 );
  92.                   endif;
  93.  
  94.                   hwndDlg = CmdGetHwndDlg( szDlg );
  95.                   SdGeneralInit( szDlg, hwndDlg, 0, szSdProduct );
  96.  
  97.                   if(szTitle != "") then
  98.                       SetWindowText( hwndDlg, szTitle );
  99.                   endif;
  100.  
  101.                   // if 32bit then hide non-applicable choice and move others up
  102.                   SdFinishInit32( szDlg, hwndDlg, bWin16 );
  103.  
  104.                   // set radiobutton
  105.                   CtrlSetState( szDlg, SD_RBUT_RESTARTWINDOWS, 0 );
  106.                   CtrlSetState( szDlg, SD_RBUT_RESTARTMACHINE, 0 );
  107.                   CtrlSetState( szDlg, SD_RBUT_NONE, 0 );
  108.                   switch (nDefOption)
  109.                   case SYS_BOOTMACHINE:
  110.                        CtrlSetState( szDlg, SD_RBUT_RESTARTMACHINE, BUTTON_CHECKED );
  111.                        hwndRbut = GetDlgItem( hwndDlg, SD_RBUT_RESTARTMACHINE );
  112.                   case SYS_BOOTWIN:
  113.                        if (bWin16) then
  114.                           CtrlSetState( szDlg, SD_RBUT_RESTARTWINDOWS, BUTTON_CHECKED );
  115.                           hwndRbut = GetDlgItem( hwndDlg, SD_RBUT_RESTARTWINDOWS );
  116.                        else
  117.                           CtrlSetState( szDlg, SD_RBUT_RESTARTMACHINE, BUTTON_CHECKED );
  118.                           hwndRbut = GetDlgItem( hwndDlg, SD_RBUT_RESTARTMACHINE );
  119.                        endif;
  120.                   default:
  121.                        CtrlSetState( szDlg, SD_RBUT_NONE, BUTTON_CHECKED );
  122.                        hwndRbut = GetDlgItem( hwndDlg, SD_RBUT_NONE );
  123.                   endswitch;
  124.  
  125.                   SetFocus( hwndRbut );
  126.  
  127.              case SD_PBUT_CONTINUE:     // Finish button
  128.                   nId   = NEXT;
  129.                   bDone = TRUE;
  130.  
  131.                   nResult = 0;
  132.  
  133.                   // determine which operation the user has selected
  134.                   if (CtrlGetState( szDlg, SD_RBUT_RESTARTWINDOWS ) = BUTTON_CHECKED) then
  135.                      nResult = SYS_BOOTWIN;
  136.                   endif;
  137.  
  138.                   if (CtrlGetState( szDlg, SD_RBUT_RESTARTMACHINE ) = BUTTON_CHECKED) then
  139.                      nResult = SYS_BOOTMACHINE;
  140.                   endif;
  141.  
  142.                   // ensure the files were commited properly
  143.                   CommitSharedFiles(0);
  144.  
  145.                   // perform operation
  146.                   if (nResult) then
  147.                      bDone = FALSE; // don't terminate dialog when rebooting
  148.  
  149.                      // record data produced by this dialog (must write before reboot)
  150.                      SdMakeName( szAppKey, szDlg, szTitle, nSdFinishReboot );
  151.                      SilentWriteData( szAppKey, "Result", DATA_NUMBER, "", nId );
  152.                      SilentWriteData( szAppKey, "BootOption", DATA_NUMBER, "", nResult );
  153.  
  154.                      nId = System( nResult );
  155.                      if ((nId = 0) && (nOS = IS_WINDOWSNT)) then
  156.                        Delay( 3 );
  157.                        nId = -1;
  158.                      elseif (nId < 0) then
  159.                        SilentWriteData( szAppKey, "Result", DATA_NUMBER, "", nId );
  160.                      endif;
  161.  
  162.                   endif;
  163.  
  164.              case SD_PBUT_BACK:
  165.                   nId = BACK; // should be disabled
  166.  
  167.              case DLG_ERR:
  168.                   SdError( -1, szDlg );
  169.                   nId   = -1;
  170.                   bDone = TRUE;
  171.  
  172.              case DLG_CLOSE:
  173.                   SdCloseDlg( hwndDlg, nId, bDone );
  174.  
  175.              default:
  176.                   // check standard handling
  177.                   if (SdIsStdButton( nId ) && SdDoStdButton( nId )) then
  178.                       bDone = TRUE;
  179.                   endif;
  180.              endswitch;
  181.  
  182.           endwhile;
  183.  
  184.           EndDialog( szDlg );
  185.           ReleaseDialog( szDlg );
  186.  
  187.           SdUnInit();
  188.           Enable( BACKBUTTON );
  189.  
  190.           // record data produced by this dialog
  191.           SdMakeName( szAppKey, szDlg, szTitle, nSdFinishReboot );
  192.           SilentWriteData( szAppKey, "Result", DATA_NUMBER, "", nId );
  193.           SilentWriteData( szAppKey, "BootOption", DATA_NUMBER, "", 0 );
  194.  
  195.           return nId;
  196.         end;
  197.  
  198.  /*------------------------------------------------------------------------*/
  199.  /*                                                                        */
  200.  /*   Function: SdFinishInit32                                             */
  201.  /*                                                                        */
  202.  /*   Descrip:  This will determine if dialog is operating under Win32     */
  203.  /*             If so it will remove the RESTARTWINDOWs option for reboot  */
  204.  /*             since that is not applicable.                              */
  205.  /*   Misc:                                                                */
  206.  /*                                                                        */
  207.  /*------------------------------------------------------------------------*/
  208. function SdFinishInit32( szDlg, hwndDlg, bWin16 )
  209.           HWND hwndRbut;
  210.         begin
  211.  
  212.         if (bWin16) then return TRUE; endif; // all options available
  213.  
  214.         hwndRbut = GetDlgItem( hwndDlg, SD_RBUT_RESTARTWINDOWS );
  215.         if (hwndRbut) then
  216.            ShowWindow( hwndRbut, SW_HIDE );
  217.         endif;
  218.  
  219.         end;
  220.  
  221.  
  222.